package com.ylxn.concurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Chapter01 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {


        FutureTask<Object> task = new FutureTask<>(new Callable<Object>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("callable is running");
                Thread.sleep(100);
                return 100;
            }
        });
        Thread thread1 = new Thread(task,"callable thread01");
        thread1.start();
        Object o = task.get();
        System.out.println("o = " + o);
    }
}
